package com.blog.video.service.impl;

import com.blog.video.dao.VideoInfoDao;

import com.blog.video.pojo.VideoInfo;
import com.blog.video.service.VideoInfoService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.blog.video.util.IdWorker;

import java.util.List;

/**
 * 这里分页使用的是pagehelper
 */
@Service
@Transactional(readOnly = false)
public class VideoServiceImpl implements VideoInfoService {

    @Autowired
    private IdWorker idWorker;

    @Autowired
    private VideoInfoDao videoDao;

    @Override
    public List<VideoInfo> findAll(int page, int size) {
        PageHelper.startPage(page, size);
        List<VideoInfo> list = videoDao.selectList(null);
        return list;
    }

    @Override
    public VideoInfo findById(String id) {
        VideoInfo video = videoDao.selectById(id);
        return video;
    }

    @Override
    public void insert(VideoInfo video) {
        videoDao.insert(video);
    }

    @Override
    public void update(VideoInfo video) {
        videoDao.updateById(video);
    }

    @Override
    public void deleteById(String id) {
        videoDao.deleteById(id);
    }
}